package com.ossjk.qlh.system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ossjk.core.base.controller.BaseController;
import com.ossjk.core.vo.RequestBean;
import com.ossjk.core.vo.ResponseBean;
import com.ossjk.qlh.loginfo.LogModule;
import com.ossjk.qlh.loginfo.LogOperation;
import com.ossjk.qlh.system.entity.Dictionary;
import com.ossjk.qlh.system.service.IDictionaryService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@LogModule(value = "系统配置管理")
@Api(tags = "系统配置管理")
@RestController
@RequestMapping("/system/systemsetting")
public class SystemsettingController extends BaseController {

	@Autowired
	private IDictionaryService iDictionaryService;

	@LogOperation("获取系统配置")
	@ApiOperation(value = "获取系统配置")
	@PostMapping(value = "/list")
	public ResponseBean<List<Dictionary>> list() {
		QueryWrapper<Dictionary> queryWrapper = new QueryWrapper<Dictionary>();
		queryWrapper.in("type", new String[] { "2", "3" });

		return responseSuccess(iDictionaryService.list(queryWrapper));
	}

	@LogOperation("修改系统配置")
	@ApiOperation(value = "修改系统配置")
	@PostMapping(value = "/update")
	public ResponseBean update(@RequestBody RequestBean<List<Dictionary>> requestBean) {
		List<Dictionary> dictionaries = requestBean.getData();
		if (iDictionaryService.updateBatchById(dictionaries)) {
			return responseSuccess();
		} else {
			return responseFail();
		}

	}
}
